from rest_framework import serializers
from .models import City, Room, Host, PasswordChangeLog, HostCountStatistics


class CitySerializer(serializers.ModelSerializer):
    class Meta:
        model = City
        fields = '__all__'


class RoomSerializer(serializers.ModelSerializer):
    city = serializers.PrimaryKeyRelatedField(queryset=City.objects.all())
    class Meta:
        model = Room
        fields = '__all__'


class HostSerializer(serializers.ModelSerializer):
    city = serializers.PrimaryKeyRelatedField(queryset=City.objects.all())
    room = serializers.PrimaryKeyRelatedField(queryset=Room.objects.all())
    class Meta:
        model = Host
        fields = '__all__'


class PasswordChangeLogSerializer(serializers.ModelSerializer):
    host = HostSerializer()

    class Meta:
        model = PasswordChangeLog
        fields = '__all__'


class HostCountStatisticsSerializer(serializers.ModelSerializer):
    city = CitySerializer()
    room = RoomSerializer()

    class Meta:
        model = HostCountStatistics
        fields = '__all__'